<?php
class BlogController extends Zend_Controller_Action
{
	public function __call($methodName, $args)
	{
		$alias = substr($methodName, 0, -6);
		$usersModel = new Blogger_Users();
		if(empty($alias) || null == ($data = $usersModel->getUserByAlias($alias)))
		{
			$this->_helper->redirector('index', 'index');
			return;
		}
		$postsModel = new Blogger_Posts();
		$paginator = $postsModel->getPaginatedPostsByUserId($data['id']);
		$pageNumber = $this->_getParam('page');
		if(!empty($pageNumber))
			$paginator->setCurrentPageNumber($pageNumber);
		$this->view->userFullName = $data['fname'].' '.$data['lname'];
		$this->view->postsPaginator = $paginator;
		$this->_helper->viewRenderer('/index/blog', null, true);
	}
	
	/*public function blogAction()
	{
		$alias = $this->_getParam('alias');
		if(empty($alias))
			throw new Blogger_Exception('Missing alias');
		
	}*/
}